<?php $this->section->begin('breadcrumb')?>
<div id="global-breadcrumb">
	<ul>
		<li><a href="<?php echo $this->url->action("index", "ControlPanel", "Product")?>">Sản phẩm</a></li>
		<li class="current">Thêm sản phẩm mới</li>
	</ul>
</div>
<?php $this->section->end()?>
<?php $this->content->begin()?>
<div class="widget-shell inner-shadow">
	<div class="widget-header">
		<h2>Thêm sản phẩm mới</h2>
	</div>
	<div class="widget-body">
		<?php
		    $ajaxOption['begin'] = "begin";
		    $ajaxOption['success'] = "success";
		    $this->form->beginAjax($ajaxOption, "Create");
		?>
			<div class="global-form">
				<div class="half margin-bottom-20">
				    <?php $this->form->labelFor("category_id", array('class' => 'normal-label'))?>
				    <?php $this->form->selectFor("category_id", $categoryOptions, null, null, array('class' => 'normal'))?>
				    <?php $this->form->validationMessage("category_id")?>
				</div>
                <div class="half margin-bottom-20">
					<?php $this->form->labelFor("name", array('class' => 'normal-label'))?>
					<?php $this->form->textboxFor("name", array('class' => 'normal'))?>
					<?php $this->form->validationMessage("name")?>
				</div>
				<div class="fclear"></div>
				<div class="half margin-bottom-20">
					<?php $this->form->labelFor("identity_name", array('class' => 'normal-label'))?>
					<?php $this->form->textboxFor("identity_name", array('class' => 'normal'))?>
					<?php $this->form->validationMessage("identity_name")?>
				</div>
                <div class="half margin-bottom-20">
					<?php $this->form->labelFor("trademark", array('class' => 'normal-label'))?>
					<?php $this->form->textboxFor("trademark", array('class' => 'normal'))?>
					<?php $this->form->validationMessage("trademark")?>
				</div>
				<div class="fclear"></div>
				<div class="half margin-bottom-20">
				    <?php $this->form->labelFor("status", array('class' => 'normal-label'))?>
				    <?php $this->form->textboxFor("status", array('class' => 'normal'))?>
				    <?php $this->form->validationMessage("status")?>
				</div>
                <div class="half margin-bottom-20">
				    <?php $this->form->labelFor("origin", array('class' => 'normal-label'))?>
				    <?php $this->form->textboxFor("origin", array('class' => 'normal'))?>
				    <?php $this->form->validationMessage("origin")?>
				</div>
                <div class="fclear"></div>
                <div class="half margin-bottom-20">
				    <?php $this->form->labelFor("shipping", array('class' => 'normal-label'))?>
				    <?php $this->form->textboxFor("shipping", array('class' => 'normal'))?>
				    <?php $this->form->validationMessage("shipping")?>
				</div>
                <div class="half margin-bottom-20">
				    <?php $this->form->labelFor("price", array('class' => 'normal-label'))?>
				    <?php $this->form->textboxFor("price", array('class' => 'normal'))?>
				    <?php $this->form->validationMessage("price")?>
				</div>
                <div class="fclear"></div>
                <div class="half margin-bottom-20">
				    <?php $this->form->labelFor("image", array('class' => 'normal-label'))?>
				    <?php $this->form->textboxFor("image", array('class' => 'normal'))?>
                    <a href="javascript:void(0)" class="button" onclick="openImageManager('image')">
							<span class="ico-text ico-text-pic"></span>Quản lý ảnh
					</a>
				    <?php $this->form->validationMessage("image")?>
				</div>
                <div class="half margin-bottom-20">
				    <?php $this->form->labelFor("subimage", array('class' => 'normal-label'))?>
				    <?php $this->form->textbox("subimage_temp", null, array('class' => 'normal'))?>
                    <?php $this->form->validationMessage("subimage")?>
                    <a href="javascript:void(0)" class="button" onclick="openImageManager('subimage_temp')">
                        <span class="ico-text ico-text-pic"></span>Quản lý ảnh
					</a>
                    <a href="javascript:void(0)" class="button" onclick="addSubImage();">
					    Thêm ảnh vào danh sách
					</a>
				    <?php $this->form->textareaFor("subimage", array('class' => 'normal'))?>
				</div>
                <div class="fclear"></div>
				<div class="margin-bottom-20">
					<?php $this->form->labelFor("headline", array('class' => 'normal-label'))?>
					<?php $this->form->textareaFor("headline", array('class' => 'normal markItUpEditor'))?>
					<?php $this->form->validationMessage("headline")?>
				</div>
				<div class="fclear"></div>
                <div class="margin-bottom-20">
                    <?php $this->form->labelFor("description", array('class' => 'normal-label'))?>
				    <div class="markItUp">
				    	<div class="markItUpContainer">
				    	    <?php $this->form->textAreaFor("description", array('class' => 'normal'))?>
				    	</div>
				    </div>
				    <?php $this->form->validationMessage("description")?>
				</div>
				<div class="fclear"></div>
				<div id="menu_type_container"></div>
			</div>
			<div class="alert alert-info alert-loading" style="margin-bottom: 0; display: none;">
				<p><span class="ico-text ico-alert-loading"></span><span>Đang thêm danh mục sản phẩm vào hệ thống...</span></p>
			</div>
			<div class="alert alert-error" style="margin-bottom: 0; display: none;">
				<p><span class="ico-text ico-alert-error"></span><span id="errorMessage"></span></p>
			</div>
			<div class="alert alert-success" style="margin-bottom: 0; display: none;">
				<p><span class="ico-text ico-alert-success"></span><span id="successMessage"></span></p>
			</div>
			<div class="global-form-footer">
				<input class="btn-theme" id="submit" type="submit" value="Thêm mới">
				<input id="reset" type="reset" value="Xóa trắng">
				<a href="<?php echo $this->url->action("index", "PCControlPanel", "Product")?>" class="button">
    				<span class="ico-text ico-text-category"></span>Danh mục sản phẩm
    			</a>
			</div>
		<?php $this->form->end()?>
	</div>
</div>
<?php $this->content->end()?>
<?php $this->section->begin("scripts")?>
<?php 
//Load js
$this->html->loadJs(array(
                        'Scripts/jquery.validate.min.js',
                        'Scripts/jquery.validate.unobtrusive.min.js',
                        'Scripts/jquery.unobtrusive-ajax.min.js',
                        'Areas/ControlPanel/Assets/js/controlpanel.js',
                        'Assets/tiny_mce/tiny_mce.js',
                        'Assets/tiny_mce/plugins/imagemanager/js/mcimagemanager.js',
                        'Areas/Product/Assets/js/tinymce.js'
                    ));
?>
<script type="text/javascript">
 function openImageManager(element)
 {
	 mcImageManager.open('Create', element);
 }
 function addSubImage()
 {
     var link = $("#subimage_temp").val();
     var subimg = $("#subimage").val();
     if(subimg == "")
         $("#subimage").val(link);
     else
         $("#subimage").val(subimg + "\n" + link);
     $("#subimage_temp").val("");
 }
</script>
<?php $this->section->end()?>